<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="layout :: common_header(~{::title})">
    <title >订单查询-拼多多店铺</title>
</head>
<body th:replace="layout :: common_body(~{::div.layui-body})">

<div class="layui-body" style="padding:15px;">
   <style>
          .update {
          display: inline-block;
          /*margin-left: 15px;*/
          /*padding: 0 20px;*/
          /*height: 40px;*/
          /*line-height: 40px;*/
          font-size: 14px;
          background: #1E9FFF;
          color: #fff;
          text-align: center;
          border-radius: 3px;
          cursor: pointer;
      }

        .update i {
            display: inline-block;
            margin-right: 5px;
            margin-left: 5px;
            vertical-align: middle;
            width: 30px;
            height: 30px;
            background: url();
        }
    </style>
    <div class="layui-tab layui-tab-brief" lay-filter="demo">
        <ul class="layui-tab-title">
            <li th:classappend="${status==1 }?'layui-this':''"><a th:href="@{/pdd/order_list(shopId=${shopId},status=1,refundStatus=1)}">待发货</a></li>
            <!-- <li><a th:href="@{/fahuo/wait_confirm_order_list_pdd(shopId=${shopId})}">待确认</a></li> -->
            <li th:classappend="${status==2 && refundStatus==1 }?'layui-this':''"><a th:href="@{/pdd/order_list(shopId=${shopId},status=2,refundStatus=1)}">已发货待签收</a></li>
            <li th:classappend="${status==null || status == -1}?'layui-this':''"><a th:href="@{/pdd/order_list(shopId=${shopId})}">全部订单</a></li>
            <li ><a th:href="@{/fahuo/wait_confirm_order_list_pdd}">待确认订单</a></li>
        </ul>
    </div>

    <!-- content starts -->
<!--    <blockquote class="layui-elem-quote">订单总览</blockquote>-->

    <fieldset class="layui-elem-field">
        <legend>按条件搜索</legend>
        <div class="layui-field-box">
            <form class="layui-form layui-form-pane1" method="get" action="/pdd/order_list">
    
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <input type="text" name="orderNum" th:value="${orderNum}" placeholder="订单编号" class="layui-input s-box" style="width: 200px" />
                    </div>
                    <div class="layui-inline">
                        <input type="text" name="goodsSpecNum" th:value="${goodsSpecNum}" placeholder="SKU编码/pddID" class="layui-input s-box"  />
                    </div>
                    <div class="layui-inline">
                        <input type="text" name="trackingNumber" th:value="${trackingNumber}" placeholder="快递单号" class="layui-input s-box"  />
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">下单时间</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="startTime" th:value="${startTime}" id="startTime" autocomplete="off"
                                   style="width: 180px;" placeholder="yyyy-MM-dd HH:mm:ss">
                        </div>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="endTime" th:value="${endTime}" id="endTime" style="width: 180px;" autocomplete="off" placeholder="yyyy-MM-dd HH:mm:ss">
                        </div>
                    </div>



                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <select name="shopId" id="shopId">
                                <option value="0">店铺</option>
                                <option  th:each="item: ${shops}" th:text="${item.name}" th:value="${item.id}">等待发货</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <select name="status" id="status">
                                <option value="-1">全部状态</option>
                                <option  th:each="item: ${T(com.b2c.entity.pdd.EnumPddOrderStatus).values()}" th:text="${item.name}" th:value="${item.index}">等待发货</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <select name="refundStatus" id="refundStatus">
                                <option value="-1">全部售后状态</option>
                                <option  th:each="item: ${T(com.b2c.entity.pdd.EnumPddOrderRefundStatus1).values()}" th:text="${item.name}" th:value="${item.pddIndex}">等待发货</option>
                            </select>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <select name="orderBy" id="orderBy">
                                <option value="1">按承诺发货时间降序</option>
                                <option value="2">按下单时间降序</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button type="submit" class="layui-btn">搜索</button>
                        <i>总共：<span style="color: red" th:text="${totalSize}"></span>条记录</i>
                    </div>
                    <div class="layui-inline">
                        <a href="javascript:;" id="export_order" style="color: #0646dc;">导出订单数据</a>
                    </div>
                    <div class="layui-inline">
                        <span id="upd_order" class="layui-btn  layui-btn-normal layui-btn-sm">拉取订单</span>
                        <span id="upd_order_" style="display: none;" class="update"><i></i>拉取中</span>

                    </div>
                    <!-- <div class="layui-inline"> -->
                    <!-- <a th:href="@{/pdd/order_excel_import(shopId=${shopId})}">excel导入代发订单数据</a> -->
                    <!-- </div> -->
                   <div class="layui-inline">
                       <span id="upd_order_status" class="layui-btn layui-btn-primary layui-btn-sm">更新当前页订单</span>
                        <span id="upd_order_status_" style="display: none;" class="update"><i></i>更新中</span>
<!--&lt;!&ndash;                        <a id="upd_order_status_all" style="display: none">更新当前订单状态</a>&ndash;&gt;-->
                   </div>
                    <div class="layui-inline" >
                        <span id="upd_order_status_all" class="layui-btn layui-btn-primary layui-btn-sm">更新当前状态订单</span>
                        <span id="upd_order_status_all_" style="display: none;" class="update layui-btn layui-btn-warm"><i></i>更新中</span>
                        <!--                        <a id="upd_order_status_all" style="display: none">更新当前订单状态</a>-->
                        
                    </div>
                    
                </div>

            </form>
        </div>
    </fieldset>

    <!-- start dd-wrapper -->
    <link rel="stylesheet" href="/goods/order.css"/>
    <div class="dd-wrapper">
        <table class="dd-table">
            <tr>
                <th width="25%">商品</th>
                <th width="5%">数量</th>
                <th width="5%">订单金额</th>
                <th width="10%">状态</th>
                <th width="20%">收货信息</th>
            
                <th width="15%">备注</th>
                <th width="10%">操作</th>
            </tr>
            <tr th:each="item:${lists}">
                <td colspan="7">
                    <table  width="100%">
                        <tr height="25px">
                            <td colspan="7" style="background-color:aliceblue" >
                               <div style="height: 25px;">
                                <span>订单编号：<i th:text="${item.orderSn}"></i></span>&nbsp;
                                <span>（<i th:text="${item.shopName}"></i>）</span>&nbsp;
                                <div style="float:right;">
                                    <span>下单时间：<i th:text="${item.createdTime}"></i></span>
                                    <!-- <span>付款时间：<i th:text="${item.payTime}"></i></span> -->
                                    <span th:if="${item.orderStatus==1 && item.refundStatus == 1}">承诺发货时间：<i style="color: red;" th:text="${item.lastShipTime}"></i></span>
                                    <span th:if="${item.orderStatus>1}">
                                        发货物流：<i  th:text="${item.trackingNumber}"></i>
                                        发货时间：<i  th:text="${item.shippingTime}"></i>
                                    </span>
                                </div>
                               </div>
                            </td>
                        </tr>
                    <tr>
                        <td width="25%">
                            <div >
                                <p style="float:left">
                                    <img th:src="${item.goodsImg}" class="pimg">
                                </p>
                                <p style="float:left">
                                    <span th:if="${#strings.isEmpty(item.goodsNickName)}" th:text="${#strings.abbreviate(item.goodsName,20)}" th:title="${item.goodsName}"></span>
                                    <span th:text="${item.goodsNickName}" ></span><br />
                                    <span th:text="${item.goodsSpecNum}"></span>
                                    <i th:if="${item.getAuditStatus()==0 }" class="layui-icon layui-icon-edit upd_goods" th:attr="d_item_id=${item.itemId}" title="修改商品"></i> 
                                    
                                    <span style="color: #3e00fa" th:text="${item.goodsSpec}"></span>
                                    <br/>
                                    ID:<span th:text="${item.pddGoodId}"></span>

        <!--                            单价: ¥[[${item.goodsPrice}]] -->
                                    
                                </p>
                                <!-- <a th:if="${item.getAuditStatus()==0 }" href="javascript:;" class="upd_goods" th:attr="d_item_id=${item.itemId}">修改商品</a> -->
                            </div>
                        </td>
                        <td width="5%"><span th:text="${item.quantity}"> </span></td>
                        <td width="5%">¥<span th:text="${item.payAmount}"></span></td>
                        <td width="10%">
        
                            <span  th:text="${T(com.b2c.entity.pdd.EnumPddOrderStatus).getName(item.orderStatus)}"></span><br/>

                            <span th:if="${item.auditStatus == 0 }" style="color: red">待确认</span>
                            <span th:if="${item.auditStatus == 1  }" style="color: rgb(13, 224, 132)">已确认</span>
                            <a th:if="${item.refundStatus !=4 &&item.auditStatus == 0}"  class="layui-btn-xs layui-btn-primary confirm"  th:attr="order-id=${item.getOrderId()}" href="javascript:;">
                                确认订单
                            </a>
                            
                            <span th:if="${item.refundStatus != 1}" >
                                <a target="_blank" th:href="@{/pdd/refund_list(num=${item.orderSn},shopId=${item.shopId})}" th:text="${T(com.b2c.entity.pdd.EnumPddOrderRefundStatus1).getName(item.refundStatus)}"> </a>
                            </span>
                        </td>

                        <td  width="20%">
                            <p th:if="${#strings.isEmpty(item.receiverName1)==false}"><span th:text="${item.receiverName1}"></span>&nbsp;&nbsp;<span th:text="${item.receiverPhone1}"></span></p>
                            <span th:if="${#strings.isEmpty(item.receiverAddress1)}" th:text="${item.area}"></span>
                            <span th:text="${item.receiverAddress1}"></span>
                            <input type="hidden" class="orderSN" th:value="${item.orderSn}">

                            
                            <a href="javascript:;" style="color: #868686" th:attr="data-id=${item.orderId}" class="hand_address ">
                                <i class="layui-icon layui-icon-location"></i>
                            </a>
                        </td>
                       
                        <td width="15%">
                            
                            <!-- <span th:attr="order-id=${item.getOrderId()},remark=${item.remark}"  class="sellerRemark">
                                <i class="layui-icon layui-icon-log"></i>
                            </span> -->
                        </td>
           
                

                        <td width="10%">
                            <a th:href="@{/pdd/orderDetail(id=${item.getOrderId()},shopId=${item.shopId})}">查看详情</a>
                            &nbsp;&nbsp;
                            <a th:attr="order-id=${item.getOrderId()},remark=${item.remark}" href="javascript:;"  class="sellerRemark">
                                添加备注
                            </a>
                            <br />
                            <span th:if="${#strings.isEmpty(item.remark)==false}" th:text="${#strings.abbreviate(item.remark,30)}" th:title="${item.remark}" style="border-color:#aea5f8;border: solid 1px;padding:1px 5px 1px 5px;background-color: #7798f4;"></span>
                            <span th:if="${#strings.isEmpty(item.result)==false}" th:text="${#strings.abbreviate(item.result,30)}" th:title="${item.result}" style="border-color:#7072eb;border: solid 1px;padding:1px 5px 1px 5px;background-color: #8e98ee;"></span>
                           <br th:if="${#strings.isEmpty(item.remark)==false || #strings.isEmpty(item.result)==false }" />
                            <a href="javascript:;" th:attr="data-id=${item.getOrderSn()},shopId=${item.shopId}" th:if="${item.orderStatus == 2  }"
                            class="order_intercept layui-btn layui-btn-disabled layui-btn-xs">拦截</a>
                           <a th:if="${item.orderStatus == 1 && item.refundStatus == 1 }" th:attr="order-id=${item.getOrderId()}" href="javascript:;" class="layui-btn-primary layui-btn-sm order_send" >发货</a>
                           
                            <!-- <a href="javascript:;" style="color: #FFFFFF" th:attr="data-id=${item.getOrderSn()}"
                              th:if="${item.refundStatus == 1}" class="layui-btn layui-btn-warm layui-btn-xs refund_apply">添加退货</a> -->
                        </td>
                    </tr>
                </table>
                </td>
                
                
            </tr>
  
        </table>
    </div>
    <!-- end dd-wrapper -->
    <div class="layui-box layui-laypage layui-laypage-default pageBox">
        <paging:pager th:value="${pageIndex}" th:rows="${totalSize}" th:size="${pageSize}"/>
    </div>
    <div id="outerdiv" style="position:fixed;top:0;left:0;background:rgba(0,0,0,0.7);z-index:2;width:100%;height:100%;display:none;">
        <div id="innerdiv" style="position:absolute;">
            <img id="bigimg" style="border:5px solid #fff;" src="" />
        </div>
    </div>

    <script type="text/template" id="modify_address">
        <div class="T-box">
            <p><span>姓名</span><input type="text" id="userName" name="userName" /></p>
            <p><span>手机号</span><input type="text" id="mobile" name="mobile" /></p>
            <p><span>收货地址</span><input type="text" id="address" name="address"/></p>
        </div>
    </script>
    <script type="text/template" id="send-goods">
        <div class="T-box">
            <p><span>快递公司</span>
                <select id="send-company">
                    <option value="">请选择快递公司</option>
                    <option th:each="item:${company}" th:value="${item.getCode()}" th:text="${item.getName()}"></option>
                </select>
            </p>
            <p><span>快递单号</span><input type="text" name="express_code"/></p>
            <p class="T-result"><span>&nbsp;</span><em id="erro"></em></p>
        </div>
    </script>
    <script type="text/javascript" src="/goods/Tips/Tips.min.js"></script>
    <script type="text/javascript">
        var layer;
        var $;
        var windowOpen;
        var confirmBtn;
        layui.use(['laydate', 'jquery', 'form', 'layer'], function () {
            var laydate = layui.laydate;
            $ = layui.jquery;
            var form = layui.form;
            layer = layui.layer;
            laydate.render({
                elem: '#startTime'
                ,type: 'datetime'
            });
            laydate.render({
                elem: '#endTime'
                ,type: 'datetime'
            });

            

            $(function () {
                $("#status").val([[${status}]]);
                $("#refundStatus").val([[${refundStatus}]]);
                $("#orderBy").val([[${orderBy}]]);
                $("#shopId").val([[${shopId}]]);
                form.render('select'); //刷新select选择框渲染


                $(".pimg").click(function(){
                    var _this = $(this);//将当前的pimg元素作为_this传入函数
                    imgShow("#outerdiv", "#innerdiv", "#bigimg", _this);
                });

                function imgShow(outerdiv, innerdiv, bigimg, _this){
                    var src = _this.attr("src");//获取当前点击的pimg元素中的src属性
                    $(bigimg).attr("src", src);//设置#bigimg元素的src属性

                    /*获取当前点击图片的真实大小，并显示弹出层及大图*/
                    $("<img/>").attr("src", src).load(function(){
                        var windowW = $(window).width();//获取当前窗口宽度
                        var windowH = $(window).height();//获取当前窗口高度
                        var realWidth = this.width;//获取图片真实宽度
                        var realHeight = this.height;//获取图片真实高度
                        var imgWidth, imgHeight;
                        var scale = 0.8;//缩放尺寸，当图片真实宽度和高度大于窗口宽度和高度时进行缩放

                        if(realHeight>windowH*scale) {//判断图片高度
                            imgHeight = windowH*scale;//如大于窗口高度，图片高度进行缩放
                            imgWidth = imgHeight/realHeight*realWidth;//等比例缩放宽度
                            if(imgWidth>windowW*scale) {//如宽度扔大于窗口宽度
                                imgWidth = windowW*scale;//再对宽度进行缩放
                            }
                        } else if(realWidth>windowW*scale) {//如图片高度合适，判断图片宽度
                            imgWidth = windowW*scale;//如大于窗口宽度，图片宽度进行缩放
                            imgHeight = imgWidth/realWidth*realHeight;//等比例缩放高度
                        } else {//如果图片真实高度和宽度都符合要求，高宽不变
                            imgWidth = realWidth;
                            imgHeight = realHeight;
                        }
                        $(bigimg).css("width",imgWidth);//以最终的宽度对图片缩放

                        var w = (windowW-imgWidth)/2;//计算图片与窗口左边距
                        var h = (windowH-imgHeight)/2;//计算图片与窗口上边距
                        $(innerdiv).css({"top":h, "left":w});//设置#innerdiv的top和left属性
                        $(outerdiv).fadeIn("fast");//淡入显示#outerdiv及.pimg
                    });

                    $(outerdiv).click(function(){//再次点击淡出消失弹出层
                        $(this).fadeOut("fast");
                    });
                }



                // if($("#status").val()==1){
                //     $("#status_menu li:nth-child(1)").addClass("layui-this");
                //     $("#status_menu li:nth-child(2)").removeClass("layui-this");
                // }else{
                //     $("#status_menu li:nth-child(2)").addClass("layui-this");
                //     $("#status_menu li:nth-child(1)").removeClass("layui-this");
                // }

                $(".s-box").keyup(function(){
                    $("#status").val('-1');
                    $("#refundStatus").val('-1');
                    form.render('select'); //刷新select选择框渲染
                })

                //变更商品
                $(".upd_goods").click(function () {
                    var $this = $(this);
                    var orderItemId =  $this.attr("d_item_id");
                    var shopId =  '[[${shopId}]]';
                    //确认订单iframe层
                    layer.open({
                        type: 2,
                        title: '修改订单商品',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['600px', '850px'],
                        content: '/pdd/order_item_upd_goods?orderItemId=' + orderItemId +'&shopId='+shopId//iframe的url
                    });

                })

                $(".sellerRemark").click(function(){
                    var id = $(this).attr('order-id');
                    var remarkT = $(this).attr('remark');
                    var obj = $(this).siblings('b').eq(0);

                    layer.prompt({
                        formType: 2,
                        value: remarkT,
                        title: '请输入备注'
                    }, function(value, index, elem){
                        var data = {id:id, remark:value};
                        $.ajax({
                            url: "/ajax_pdd/order_remark_ajax",
                            type: "POST",
                            dataType: "JSON",
                            contentType: 'application/json',
                            data:JSON.stringify(data),
                            success: function (res) {

                                if(res.code == 0){

                                    $(obj).text(value);
                                    layer.close(index)
                                    layer.msg(res.msg);
                                    // location=location;
                                }else
                                    layer.alert(res.msg);
                            }
                        });


                });
            });

            //补充收货地址
            $('.hand_address').click(function (e) {
                e.stopPropagation();
                e.preventDefault();
                var id = $(this).attr('data-id');
                Tips.confirm({
                    title: '补充收货地址',
                    content: $('#modify_address').html(),
                    define: function () {
                        var data = {
                            id: id,
                            name: $("input[name='userName']").val(),
                            mobile: $("input[name='mobile']").val(),
                            address: $("input[name='address']").val()
                        };
                        $.ajax({
                            url: "/ajax_pdd/order_hand_address",
                            type: "POST",
                            dataType: 'json',
                            contentType: 'application/json',
                            data: JSON.stringify(data),
                            success: function (res) {
                                if (res.code == 0) {
                                    Tips.alert('成功', function () {
                                        location.reload(true);
                                    });
                                } else {
                                    Tips.alert(res.msg);
                                }
                            }
                        });
                    }
                });
            });

                //拦截订单（退货）
                $(".order_intercept").click(function () {
                    var $this = $(this);
                    let orderSn = $(this).attr('data-id');
                    let shopId = $(this).attr('shopId');

                    if(confirm("该操作不可逆，是否拦截订单？")){
                        var data = {
                            orderSn: orderSn,
                            shopId:shopId,
                            msg:"拦截订单",
                            afterType:9
                        };
                        console.log(data);
                        $.ajax({
                            url: "/ajax_pdd/order_intercept",
                            type: "POST",
                            dataType: 'json',
                            contentType: 'application/json',
                            data: JSON.stringify(data),
                            success: function (res) {
                                if (res.code == 0) {
                                    layer.msg("拦截成功");
                                    location.reload(true);
                                    // Tips.alert('成功', function () {
                                    //     location.reload(true);
                                    // });
                                } else {
                                    alert(res.msg);
                                    return false;
                                }
                            }
                        });
                    }

                })

                 


                //更新订单
                $("#upd_order").click(function () {
                    var shopId = $("#shopId").val();
                    if(shopId==0||shopId == ''||shopId =='null'||shopId==null) {alert("请选择店铺");return;}

                    if(!confirm("要拉取订单吗？")) return;
                    
                    let startTime = $("#startTime").val();
                    let endTime = $("#endTime").val();
                    
                    
                    $("#upd_order").hide();
                    $("#upd_order_").show();
                    let data = {
                        startTime:startTime,
                        endTime:endTime,
                        updType:0,
                        shopId:shopId
                    };

                    $.ajax({
                        url: "/ajax_pdd/pull_order",
                        type: "POST",
                        dataType: "JSON",
                        contentType: 'application/json',
                        data:JSON.stringify(data),
                        success: function (res) {
                            if (res.code == 0) {
                                Tips.alert({
                                    title: '更新订单',
                                    content: '更新结果：'+res.msg+'【'+JSON.stringify(res.data )+'】',
                                    define: function () {
                                        // location.href = "/pdd/order_list?shopId="+shopId;
                                        location.reload();
                                    }
                                });
                            }else if(res.code==601){
                                // $("#upd_order").show();
                                // $("#upd_order_").hide();
                                alert(res.msg);
                                // Tips.alert(res.msg);
                                location.href = "/pdd/oauth?shopId="+shopId;
                            }
                            else {

                                Tips.alert(res.msg);
                            }
                            $("#upd_order").show();
                            $("#upd_order_").hide();
                        }
                    })
                });

                //更新当前页订单状态
                $("#upd_order_status").click(function () {
                    $("#upd_order_status").hide();
                    $("#upd_order_status_").show();
                    //组合订单号
                    var orderS = "";
                    $(".orderSN").each(function () {
                        orderS += $(this).val()+",";
                    });
                    //alert(orderS);
                    // let startTime = $("#startTime").val();
                    // let endTime = $("#endTime").val();
                    var shopId = $("#shopId").val();
                    if(shopId==0) {alert("请选择店铺");return;}

                    let data = {
                        orderS:orderS,
                        shopId: shopId
                    };

                    $.ajax({
                        url: "/ajax_pdd/pull_order_status",
                        type: "POST",
                        dataType: "JSON",
                        contentType: 'application/json',
                        data:JSON.stringify(data),
                        success: function (res) {
                            if (res.code == 0) {
                                layer.msg("订单状态更新成功");
                                //window.location.reload();
                                // Tips.alert({
                                //     title: '更新订单',
                                //     content: '订单状态更新成功',
                                //     define: function () {
                                //         location.href = "/pdd/orderList?shopId="+shopId;
                                //     }
                                // });
                            }else if(res.code==601){
                                // $("#upd_order").show();
                                // $("#upd_order_").hide();
                                alert(res.msg);
                                // Tips.alert(res.msg);
                                location.href = "/pdd/oauth?shopId="+shopId;
                            }
                            else {
                                Tips.alert(res.msg);
                            }
                            $("#upd_order_status").show();
                            $("#upd_order_status_").hide();
                        }
                    })
                });



                //更新当前订单状态
                $("#upd_order_status_all").click(function () {
                    if(!confirm("要更新订单吗？")) return;
                    
                    var shopId = $("#shopId").val();
                    if(shopId==0) {alert("请选择店铺");return;}

                    $("#upd_order_status_all").hide();
                    $("#upd_order_status_all_").show();
                    let data = {
                        orderStatus: '[[${status}]]',
                        refundStatus: '[[${refundStatus}]]',
                        shopId: shopId
                    };

                    $.ajax({
                        url: "/ajax_pdd/pull_order_status_all",
                        type: "POST",
                        dataType: "JSON",
                        contentType: 'application/json',
                        data:JSON.stringify(data),
                        success: function (res) {
                            
                            if (res.code == 0) {
                                layer.msg("订单状态更新成功");
                                Tips.alert({
                                    title: '更新订单',
                                    content: '更新结果：【'+res.msg+'】',
                                    define: function () {
                                        location.reload();
                                    }
                                });
                                //Tips.alert("订单状态更新成功");
                                //window.location.reload();
                                // Tips.alert({
                                //     title: '更新订单',
                                //     content: '订单状态更新成功',
                                //     define: function () {
                                //         location.href = "/pdd/orderList?shopId="+shopId;
                                //     }
                                // });
                            }else if(res.code==601){
                                // $("#upd_order").show();
                                // $("#upd_order_").hide();
                                alert(res.msg);
                                // Tips.alert(res.msg);
                                location.href = "/pdd/oauth?shopId="+shopId;
                            }
                            else {
                                Tips.alert(res.msg);
                            }
                            $("#upd_order_status_all").show();
                            $("#upd_order_status_all_").hide();
                        }
                    })
                });

                $("#export_order").click(function () {
                    var urlLink = window.location.href;
                    var exportLink = "/pdd/order_list_export?shopId=[[${shopId}]]&status="+$('#status').val()+"&startTime="+$('#startTime').val()+"&endTime="+$("#endTime").val();
                    window.open(exportLink);
                });



            // 填写物流发货
            $('.order_send').click(function (e) {
                e.stopPropagation();
                e.preventDefault();
                var orderId = $(this).attr('order-id');
                Tips.confirm({
                    title: '手动填写物流信息',
                    content: $('#send-goods').html(),
                    define: function () {
                        var data = {
                            orderId: orderId,
                            company: $("#send-company  option:selected").text(),
                            companyCode: $("#send-company  option:selected").val(),
                            code: $("input[name='express_code']").val()
                        };
                        $.ajax({
                            url: "/ajax_pdd/pdd_order_send",
                            type: "POST",
                            dataType: 'json',
                            contentType: 'application/json',
                            data: JSON.stringify(data),
                            success: function (res) {
                                if (res.code == 0) {
                                    Tips.alert('成功', function () {
                                        location.reload(true);
                                    });
                                } else {
                                    Tips.alert(res.msg);
                                }
                            }
                        });
                    }
                });
            });

            //确认订单
            $(".confirm").click(function () {
                    var $this = $(this);
                    confirmBtn = $this;
                    var orderId = $(this).attr("order-id");
                    //确认订单iframe层
                    layer.open({
                        type: 2,
                        title: '订单确认',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['480px', '750px'],
                        content: '/pdd/order_confirm?orderId=' + orderId  //iframe的url
                    });
                });



            })
        });

        function confirm_order(){
            layer.msg("确认成功");
            $(confirmBtn).remove();
        }

    </script>

    <!-- 模板  -->
    <script type="text/template" id="tpl-group">
        <div class="T-box" style="width: 1000px">
            <div class="dd-log">
                <ul id="sendContext">
                </ul>
            </div>
        </div>
    </script>


</div>
</body>
<html>
